1181A - Chunga-Changa - CodeForces Solution


greedy math *1000

Please click on ads to support us..

Python Code:

x, y, z = list(map(int, input().split()))
c1 = (x + y) // z
c2 = x // z + y // z
if c1 == c2:
    print(c1, 0)
else:
    print(c1, z - max(x % z, y % z))

C++ Code:

#include<iostream>
#include<bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
    #endif

    long long int x,y,z;
    cin>>x>>y>>z;
    long long int total = (x + y)/z;
    long long int notransfer = x/z + y/z;
    cout << total << " ";
    long long int a = z - (x%z);
    long long int b = z - (y%z);
    if(total > notransfer){
        cout << min(a,b);
    }
    else{
        cout << 0;
    }
 
    return 0;
	
}


Comments

Submit
0 Comments
More Questions

Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people
Book of Potion making
Duration
Birthday Party
e-maze-in
Bricks Game
Char Sum
Two Strings
Anagrams
Prime Number
Lexical Sorting Reloaded
1514A - Perfectly Imperfect Array
580A- Kefa and First Steps
1472B- Fair Division
996A - Hit the Lottery
MSNSADM1 Football
MATCHES Playing with Matches
HRDSEQ Hard Sequence
DRCHEF Doctor Chef